<#assign ctrl_base_name = "GridControlBase"/>
<#assign import_block>
import { FormItemModel } from '@/model/form-detail';
</#assign>
<#ibizinclude>
../@MACRO/CONTROL/CONTROL_HEADER-BASE.vue.ftl
</#ibizinclude>
<#ibizinclude>
../@MACRO/FUNC/MACRO.ftl
</#ibizinclude>
<#macro getMajorInfoColName ctrl>
<#compress>
<#if ctrl.getPSDEGridColumns?? && ctrl.getPSDEGridColumns()??>
<#list ctrl.getPSDEGridColumns() as gridColumn>
<#if gridColumn.getPSAppDEField?? && gridColumn.getPSAppDEField()??>
<#assign majorInfoField = gridColumn.getPSAppDEField() />
<#if majorInfoField.isMajorField()>
${gridColumn.getName()}
</#if>
</#if>
</#list>
</#if>
</#compress>
</#macro>

    /**
     * 界面行为模型
     *
     * @type {*}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */  
    public ActionModel: any = {
    <#if ctrl.getPSUIActions()??>
    <#list ctrl.getPSUIActions() as item>
        ${item.getUIActionTag()}: { name: '${item.getUIActionTag()}',disabled: false, visabled: true,noprivdisplaymode:<#if item.getNoPrivDisplayMode(view)??>${item.getNoPrivDisplayMode(view)}</#if>,dataaccaction: '<#if item.getDataAccessAction()??>${item.getDataAccessAction()}</#if>', actiontarget: '${item.getActionTarget()}'}<#if item_has_next>,</#if>
    </#list>
    </#if>  
    };

    /**
     * 主信息表格列
     *
     * @type {string}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */  
    public majorInfoColName:string = "<@getMajorInfoColName ctrl/>";

<#if ctrl.getAllPSDEGridColumns?? && ctrl.getAllPSDEGridColumns()??>
    <#list ctrl.getAllPSDEGridColumns() as column>
        <#if column.getPSAppDEField?? && column.getPSAppDEField()?? && column.getPSAppDEField().isKeyField() && appde.getKeyPSAppDEField()?? && appde.getKeyPSAppDEField().getCodeName() == column.getPSAppDEField().getCodeName()>
    /**
     * 列主键属性名称
     *
     * @type {string}
     * @memberof ${srfclassname(ctrl.codeName)}${srfclassname(ctrl.getControlType()?lower_case)}Base
     */
    public columnKeyName: string = "${column.getName()?lower_case}";
        </#if>
    </#list>
</#if>

    /**
     * 本地缓存标识
     *
     * @protected
     * @type {string}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    protected localStorageTag: string = '${ctrl.getPSAppDataEntity().getName()?lower_case}_${ctrl.getCodeName()?lower_case}_${ctrl.name}';
<#if ctrl.isEnablePagingBar() == false>

    /**
     * 是否支持分页
     *
     * @type {boolean}
     * @memberof ${srfclassname(ctrl.codeName)}${srfclassname(ctrl.getControlType()?lower_case)}Base
     */
    public isEnablePagingBar: boolean = false;
</#if>
<#if ctrl.isNoSort() == true>

    /**
     * 是否禁用排序
     *
     * @type {boolean}
     * @memberof ${srfclassname(ctrl.codeName)}${srfclassname(ctrl.getControlType()?lower_case)}Base
     */
    public isNoSort: boolean = ${ctrl.isNoSort()?c};
</#if>
<#if ctrl.getMinorSortDir()?? && ctrl.getMinorSortDir() != "">

    /**
     * 排序方向
     *
     * @type {string}
     * @memberof ${srfclassname(ctrl.codeName)}${srfclassname(ctrl.getControlType()?lower_case)}Base
     */
    public minorSortDir: string = '${ctrl.getMinorSortDir()}';
</#if>
<#if ctrl.getMinorSortPSDEF()?? && ctrl.getMinorSortPSDEF() != "">

    /**
     * 排序字段
     *
     * @type {string}
     * @memberof ${srfclassname(ctrl.codeName)}${srfclassname(ctrl.getControlType()?lower_case)}Base
     */
    public minorSortPSDEF: string = '${ctrl.getMinorSortPSDEF().getCodeName()?lower_case}';
</#if>
<#if ctrl.getPagingSize() != 20>

    /**
     * 分页条数
     *
     * @type {number}
     * @memberof ${srfclassname(ctrl.codeName)}${srfclassname(ctrl.getControlType()?lower_case)}Base
     */
    public limit: number = ${ctrl.getPagingSize()?c};
</#if>
<#if ctrl.isHideHeader() == true>

    /**
     * 是否显示标题
     *
     * @type {boolean}
     * @memberof ${srfclassname(ctrl.codeName)}${srfclassname(ctrl.getControlType()?lower_case)}Base
     */
    public isHideHeader: boolean = ${ctrl.isHideHeader()?c};
</#if>
<#if ctrl.getAggMode() == "ALL" && ctrl.getAggPSDEAction()??>

    /**
     * 表格聚合行为
     *
     * @type {string}
     * @memberof ${srfclassname(ctrl.codeName)}${srfclassname(ctrl.getControlType()?lower_case)}Base
     */
    public aggAction:string ='${ctrl.getAggPSDEAction().getCodeName()}';
</#if>
<#if ctrl.getQuickPSDEToolbar?? && ctrl.getQuickPSDEToolbar()??>
    <#assign quickToolbar = ctrl.getQuickPSDEToolbar()/>

    ${P.getCtrlCode(quickToolbar, 'CONTROL.vue').code}
</#if>
<#if ctrl.getBatchPSDEToolbar?? && ctrl.getBatchPSDEToolbar()??>
    <#assign batchToolbar = ctrl.getBatchPSDEToolbar()/>

    ${P.getCtrlCode(batchToolbar, 'CONTROL.vue').code}
</#if>
<#if ctrl.getAggMode() == "ALL">

    /**
     * 表格是否显示
     *
     * @type {boolean}
     * @memberof ${srfclassname(ctrl.codeName)}${srfclassname(ctrl.getControlType()?lower_case)}Base
     */
    public isDisplay: boolean = false;
</#if>
<#if app.getPSApplicationUI()?? && app.getPSApplicationUI().getPFStyleParam('EL-TABLE.CHECKCOLWIDTH', 35) != 35>

    /**
    * 选项框列宽
    *
    * @type {number}
    * @memberof ${srfclassname(ctrl.codeName)}${srfclassname(ctrl.getControlType()?lower_case)}Base
    */
    public checkboxColWidth: number = ${app.getPSApplicationUI().getPFStyleParam('EL-TABLE.CHECKCOLWIDTH', 35)};
</#if>
<#if app.getPSApplicationUI()?? && app.getPSApplicationUI().getPFStyleParam('EL-TABLE.ISDRAGENDCOL', false) != false>

    /**
     * 是否允许拖动列宽
     *
     * @type {boolean}
     * @memberof ${srfclassname(ctrl.codeName)}${srfclassname(ctrl.getControlType()?lower_case)}Base
     */
    public isDragendCol: boolean = ${app.getPSApplicationUI().getPFStyleParam('EL-TABLE.ISDRAGENDCOL', false)?c};
</#if>
<#if ctrl.getPSDEDataImport?? && ctrl.getPSDEDataImport()??>

    /**
     * 是否为实体导出对象
     *
     * @protected
     * @type {boolean}
     * @memberof ${srfclassname(ctrl.codeName)}${srfclassname(ctrl.getControlType()?lower_case)}Base
     */
    protected isDeExport: boolean = true;
</#if>

    /**
     * 所有列成员
     *
     * @type {any[]}
     * @memberof ${srfclassname(ctrl.codeName)}${srfclassname(ctrl.getControlType()?lower_case)}Base
     */
    public allColumns: any[] = [
        <#if ctrl.getAllPSDEGridColumns()??>
        <#list ctrl.getAllPSDEGridColumns() as column>
        {
            name: '${column.getName()?lower_case}',
            label: '${column.getCaption()}',
            langtag: '<#if langbase??>${langbase}.columns.${column.getName()?lower_case}</#if>',
            show: <#if column.isHideDefault()>false<#else>true</#if>,
            unit: '${column.getWidthUnit()}',
    <#--  BEGIN：是否支持行编辑  -->
    <#if ctrl.isEnableRowEdit() && column.isEnableRowEdit()>
            isEnableRowEdit: true,
    <#else>
            isEnableRowEdit: false,
    </#if>
    <#--  END：是否支持行编辑  -->
    <#--  BEGIN：是否启用  -->
    <#if column.getEnableCond?? && column.getEnableCond()??>
            enableCond: ${column.getEnableCond()?c} ,
    <#else>
            enableCond: 3 ,
    </#if>
    <#--  END：是否启用  -->
        },
        </#list>
        </#if>
    ]
<#--  计算表格行编辑个数  -->
<#assign getGridRowModelCount = 0/>
<#list ctrl.getPSDEGridEditItems() as edititem>
<#assign getGridRowModelCount += 1/>
</#list>
<#if getGridRowModelCount gt 0>

    /**
     * 获取表格行模型
     *
     * @type {*}
     * @memberof ${srfclassname(ctrl.codeName)}${srfclassname(ctrl.getControlType()?lower_case)}Base
     */
    public getGridRowModel(){
        return {
<#list ctrl.getPSDEGridEditItems() as edititem>
          ${edititem.getName()}: new FormItemModel(),
</#list>
        }
    }

    /**
     * 属性值规则
     *
     * @type {*}
     * @memberof ${srfclassname(ctrl.codeName)}${srfclassname(ctrl.getControlType()?lower_case)}Base
     */
    public rules() {
        return {
        <#list ctrl.getPSDEGridEditItems() as edititem>
        ${edititem.getName()}: [
            { required: <#if edititem.isAllowEmpty()>false<#else>true</#if>, validator: (rule:any, value:any, callback:any) => { return (rule.required && (value === null || value === undefined || value === "")) ? false : true;}, message: <#if edititem.getCaption?? && edititem.getCaption()??>'${edititem.getCaption()} 值不能为空'<#else>'值不能为空'</#if>, trigger: 'change' },
            { required: <#if edititem.isAllowEmpty()>false<#else>true</#if>, validator: (rule:any, value:any, callback:any) => { return (rule.required && (value === null || value === undefined || value === "")) ? false : true;}, message: <#if edititem.getCaption?? && edititem.getCaption()??>'${edititem.getCaption()} 值不能为空'<#else>'值不能为空'</#if>, trigger: 'blur' },
          <#if ctrl.getPSDEGridEditItemVRs?? && ctrl.getPSDEGridEditItemVRs()??>
            <#list ctrl.getPSDEGridEditItemVRs() as fideValueRule>
              <#if fideValueRule.getPSDEGridEditItemName() == edititem.getName()>
                <#if fideValueRule.getPSSysValueRule()??>
                  <#assign  valueRule = fideValueRule.getPSSysValueRule()/>
                  <#if valueRule.getRuleType?? && valueRule.getRuleType()??>
                    <#if valueRule.getRuleType() == "REG">
            { <#if valueRule.getRegExCode?? && valueRule.getRegExCode()??>pattern: /${valueRule.getRegExCode()}/</#if><#if valueRule.getRuleInfo?? &&  valueRule.getRuleInfo()??>, message: '${valueRule.getRuleInfo()}'</#if>, trigger: 'change' },
                    <#elseif valueRule.getRuleType() == "SCRIPT">
            { <#if valueRule.getScriptCode?? && valueRule.getScriptCode()??>validator: (rule:any, value:any, callback:any) => { ${valueRule.getScriptCode()} }</#if><#if valueRule.getRuleInfo?? &&  valueRule.getRuleInfo()??>, message: '${valueRule.getRuleInfo()}'</#if>, trigger: 'change' },
                    </#if>
                  </#if>
                </#if>
                <#if fideValueRule.getPSDEFValueRule()??>
                <#assign  valueRule = fideValueRule.getPSDEFValueRule()/>
                    <#if fideValueRule.getPSDEGridEditItemName?? && fideValueRule.getPSDEGridEditItemName()??>
            {validator:(rule:any, value:any, callback:any)=>{return this.verifyDeRules("${fideValueRule.getPSDEGridEditItemName()}",this.deRules,"AND",value).isPast},message: "<#if valueRule.getRuleInfo()??>${valueRule.getRuleInfo()}</#if>", trigger: 'blur' },
                    </#if>
                </#if>
              </#if>
            </#list>
          </#if>
        ],
        </#list>
    }
    }

    /**
     * 属性值规则
     *
     * @type {*}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public deRules:any = {
        <#if ctrl.getPSDEGridEditItemVRs?? && ctrl.getPSDEGridEditItemVRs()??>
        <#list ctrl.getPSDEGridEditItemVRs() as fideValueRule>
            <#if fideValueRule.getCheckMode?? && fideValueRule.getCheckMode()?? && fideValueRule.getCheckMode() != 2 && fideValueRule.getPSDEFValueRule?? && fideValueRule.getPSDEFValueRule()??>
                <#assign  deRule = fideValueRule.getPSDEFValueRule()/>
                <#if fideValueRule.getPSDEGridEditItemName?? && fideValueRule.getPSDEGridEditItemName()??>
                ${fideValueRule.getPSDEGridEditItemName()}:[
                <#if deRule.getPSDEFVRGroupCondition?? && deRule.getPSDEFVRGroupCondition()?? && deRule.getPSDEFVRGroupCondition().getPSDEFVRConditions?? &&  deRule.getPSDEFVRGroupCondition().getPSDEFVRConditions()??>
                <#list deRule.getPSDEFVRGroupCondition().getPSDEFVRConditions() as condItem>
                    <@getDeRule condItem />
                </#list>
                </#if>],
                </#if>
            </#if>
        </#list>
        </#if>
    };
</#if>

    /**
     * 获取对应列class
     *
     * @type {*}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public hasRowEdit: any = {
<#list ctrl.getPSDEGridColumns() as column>
<#if ctrl.isEnableRowEdit() && column.isEnableRowEdit()>
        '${column.getName()?lower_case}':true,
<#else>
        '${column.getName()?lower_case}':false,
</#if>
</#list>
    };

    /**
     * 获取对应列class
     *
     * @param {*} $args row 行数据，column 列数据，rowIndex 行索引，列索引
     * @returns {void}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public getCellClassName(args: {row: any, column: any, rowIndex: number, columnIndex: number}): any {
        return ( this.hasRowEdit[args.column.property] && this.actualIsOpenEdit ) ? "edit-cell" : "info-cell";
    }

<#if ctrl.getPSDEDataImport?? && ctrl.getPSDEDataImport()??>
    /**
     * 数据导入
     *
     * @param {*} data
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
     public importExcel(data:any ={}):void{
        //导入excel
        const importDataModel:any ={
            <#assign dataImport = ctrl.getPSDEDataImport() />
            importId:'${dataImport.getCodeName()}',
            serviceName:'${dataImport.getPSAppDataEntity().getCodeName()?lower_case}',
            appDeLogicName:'${dataImport.getPSAppDataEntity().getLogicName()}',
            importData:{
            <#if dataImport.getPSDEDataImportItems()??>
            <#list dataImport.getPSDEDataImportItems() as dataImportItem>
            "${dataImportItem.getName()}":{<#if dataImportItem.getPSCodeList()??><#assign codelist = dataImportItem.getPSCodeList()/>"codelist":{"type":"${codelist.getCodeListType()}","tag":"${codelist.getCodeName()}","isnumber":${codelist.isCodeItemValueNumber()?c}},</#if>"headername":"${dataImportItem.getCaption()}","isuniqueitem":${dataImportItem.isUniqueItem()?c},<#if dataImportItem.getPSAppDEField()??><#assign appDeField = dataImportItem.getPSDEField()/>"name":"${appDeField.getCodeName()?lower_case}","order":<#if appDeField.getImportOrder()??>${appDeField.getImportOrder()?c}</#if></#if>}<#if dataImportItem_has_next>,</#if>
            </#list>
            </#if>
            }
        }
        if(Object.keys(importDataModel).length == 0){
            this.$Notice.warning({ 'title': (this.$t("app.utilview.warning") as string), 'desc': (this.$t("app.utilview.info") as string) });
            return;
        }
        const view:any ={
            viewname: 'app-data-upload',
            title: this.$t("app.utilview.importview"),
            width: 900,
            height: 700
        }
        let container: Subject<any> = this.$appmodal.openModal(view, JSON.parse(JSON.stringify(this.context)), importDataModel);
        container.subscribe((result: any) => {
          if(Object.is(result.ret,'OK')){
            this.refresh(result.datas);
          }
      });
    }
</#if>
<#assign hasDEExport = false/>
<#if ctrl.getPSDEDataExport?? && ctrl.getPSDEDataExport()??>
<#assign hasDEExport = true/>

    /**
     * 是否为实体导出对象
     *
     * @protected
     * @type {boolean}
     * @memberof ${srfclassname(ctrl.codeName)}${srfclassname(ctrl.getControlType()?lower_case)}Base
     */
    protected isDeExport: boolean = true;

    /**
     * 所有导出列成员
     *
     * @type {any[]}
     * @memberof ${srfclassname(ctrl.codeName)}${srfclassname(ctrl.getControlType()?lower_case)}Base
     */
    public allExportColumns: any[] = [
        <#if ctrl.getPSDEDataExport().getPSDEDataExportItems()??>
        <#list ctrl.getPSDEDataExport().getPSDEDataExportItems() as column>
        {
            name: '${column.getName()?lower_case}',
            label: '${column.getCaption()}',
            langtag: '<#if langbase??>${langbase}.exportColumns.${column.getName()?lower_case}</#if>',
            show: true,
        },
        </#list>
        </#if>
    ]
</#if>
<#assign formatExcelDataCount = 0/>
<#if hasDEExport>
  <#assign exportItems = ctrl.getPSDEDataExport().getPSDEDataExportItems() />
<#else>
  <#assign exportItems = ctrl.getAllPSDEGridColumns() />
</#if>
<#if exportItems??>
    <#list exportItems as column>
    <#assign formatExcelDataCount += 1/>
    </#list>
</#if>
<#if formatExcelDataCount gt 0>

    /**
     * 导出数据格式化
     *
     * @param {*} filterVal
     * @param {*} jsonData
     * @param {any[]} [codelistColumns=[]]
     * @returns {Promise<any>}
     * @memberof ${srfclassname(ctrl.codeName)}${srfclassname(ctrl.getControlType()?lower_case)}Base
     */
    public async formatExcelData(filterVal: any, jsonData: any, codelistColumns?: any[]): Promise<any> {
        return super.formatExcelData(filterVal, jsonData, [
<#if ctrl.getPSDEDataExport()?? && ctrl.getPSDEDataExport().getPSDEDataExportItems()??>
  <#list ctrl.getPSDEDataExport().getPSDEDataExportItems() as column>
     <#if column.getPSCodeList?? && column.getPSCodeList()??>
      <#assign codelist = column.getPSCodeList()>
      <#if codelist.getCodeListType() == 'STATIC' || codelist.getCodeListType() == 'DYNAMIC'>
            {
                name: '${column.getName()?lower_case}',
                srfkey: '${codelist.codeName}',
                codelistType : '${codelist.getCodeListType()}',
            <#if codelist.getOrMode() == 'STR'>
                textSeparator: '${codelist.textSeparator}',
                renderMode: 'string',
                valueSeparator: "${codelist.valueSeparator}",
            <#elseif codelist.getOrMode() == 'NUM'>
                renderMode: 'number',
                textSeparator: '${codelist.textSeparator}',
                valueSeparator: ',',
            <#else>
                renderMode: 'other',
                textSeparator: '、',
                valueSeparator: ',',
            </#if>
            },
      </#if>
     </#if>
  </#list>
  <#else>
  <#if ctrl.getAllPSDEGridColumns()??>
    <#list ctrl.getAllPSDEGridColumns() as column>
     <#if (!column.isHideDefault() && column.getName() != '') && column.getPSCodeList?? && column.getPSCodeList()?? && column.getCLConvertMode() == 'FRONT'>
      <#assign codelist = column.getPSCodeList()>
      <#if codelist.getCodeListType() == 'STATIC' || codelist.getCodeListType() == 'DYNAMIC'>
            {
                name: '${column.getName()?lower_case}',
                srfkey: '${codelist.codeName}',
                codelistType : '${codelist.getCodeListType()}',
            <#if codelist.getOrMode() == 'STR'>
                textSeparator: '${codelist.textSeparator}',
                renderMode: 'string',
                valueSeparator: "${codelist.valueSeparator}",
            <#elseif codelist.getOrMode() == 'NUM'>
                renderMode: 'number',
                textSeparator: '${codelist.textSeparator}',
                valueSeparator: ',',
            <#else>
                renderMode: 'other',
                textSeparator: '、',
                valueSeparator: ',',
            </#if>
            },
      </#if>
     </#if>
    </#list>
  </#if>
</#if>
        ]);
    }
</#if>
<#if ctrl.getAggMode() != "NONE">

    /**
     * 合计行绘制
     *
     * @param {any} param
     * @memberof ${srfclassname(ctrl.codeName)}${srfclassname(ctrl.getControlType()?lower_case)}Base
     */
    public getSummaries(param:any){
    <#if ctrl.getAggMode() == "PAGE">
        const { columns, data } = param;
        const sums:Array<any> = [];
        columns.forEach((column:any, index:number) => {
          if (index === 0) {
            sums[index] = (this.$t('app.gridpage.sum') as string);
            return;
          }
          if(index === (columns.length - 1)){
            sums[index] = '';
            return;
          }
          const values = data.map((item:any) => Number(item[column.property]));
          if (!values.every((value:any) => isNaN(value))) {
            <#if ctrl.getPSDEGridColumns()??>
            <#list ctrl.getPSDEGridColumns() as singleColumn>
            <#if singleColumn.getAggMode() == "SUM">
                if(Object.is(column.property,'${singleColumn.getCodeName()?lower_case}')){
                    let tempData = values.reduce((prev:any, curr:any) => {
                        const value = Number(curr);
                        if (!isNaN(value)) {
                            return prev + curr;
                        } else {
                            return prev;
                        }
                    }, 0);
                    sums[index] = tempData;
                }
            <#elseif singleColumn.getAggMode() == "AVG">
                if(Object.is(column.property,'${singleColumn.getCodeName()?lower_case}')){
                    let tempData = values.reduce((prev:any, curr:any) => {
                        const value = Number(curr);
                        if (!isNaN(value)) {
                            return prev + curr;
                        } else {
                            return prev;
                        }
                    }, 0);
                    sums[index] = tempData/data.length;
                }
            <#elseif singleColumn.getAggMode() == "MAX">
                if(Object.is(column.property,'${singleColumn.getCodeName()?lower_case}')){
                    let tempData:any;
                    values.forEach((item:any) =>{
                    const value = Number(item);
                        if (!isNaN(value)) {
                            if(!tempData){
                                tempData = value;
                            }
                            if(value > tempData){
                                tempData = value;
                            }
                        }
                    });
                    sums[index] = tempData;
                }
            <#elseif singleColumn.getAggMode() == "MIN">
                if(Object.is(column.property,'${singleColumn.getCodeName()?lower_case}')){
                    let tempData:any;
                    values.forEach((item:any) =>{
                    const value = Number(item);
                        if (!isNaN(value)) {
                            if(!tempData){
                                tempData = value;
                            }
                            if(value < tempData){
                                tempData = value;
                            }
                        }
                    });
                    sums[index] = tempData;
                }
            </#if>
            </#list>
            </#if>
          } else {
            sums[index] = 'N/A';
          }
        });
        return sums;
    <#elseif ctrl.getAggMode() == "ALL">
        const { columns } = param;
        const sums:Array<any> = [];
        columns.forEach((column:any, index:number) => {
        if (index === 0) {
            sums[index] = (this.$t('app.gridpage.sum') as string);
            return;
        }else if(index === (columns.length - 1)){
            sums[index] = '';
            return;
        }else{
        <#if ctrl.getPSDEGridColumns()??>
            sums[index] = 'N/A';
        <#list ctrl.getPSDEGridColumns() as singleColumn>
            <#if singleColumn.getAggMode() != "NONE">
            if(Object.is(column.property,'${singleColumn.getCodeName()?lower_case}')){
                const value = Number(this.remoteData.${singleColumn.getCodeName()?lower_case});
                if (!isNaN(value)) {
            <#if singleColumn.getAggMode() == "SUM">
                    sums[index] =  value;
            <#elseif singleColumn.getAggMode() == "AVG">
                    sums[index] =  value;
            <#elseif singleColumn.getAggMode() == "MAX">
                    sums[index] =  value;
            <#elseif singleColumn.getAggMode() == "MIN">
                    sums[index] =  value;
            </#if>
                }
            }
            </#if>
        </#list>
        </#if>
        }
        });
        return sums; 
    </#if>
      }
</#if>

<#if ctrl.getAggMode() == "ALL">
    /**
     * 远程获取合计行数据
     *
     * @memberof ${srfclassname(ctrl.codeName)}${srfclassname(ctrl.getControlType()?lower_case)}Base
     */
    public getAggData(){
        this.service.getAggData(this.aggAction,JSON.parse(JSON.stringify(this.context)),this.showBusyIndicator).then((response:any) =>{
            if (!response.status || response.status !== 200) {
                if (response.errorMessage) {
                    this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.errorMessage });
                }
                return;
            }
            this.remoteData = response.data;
            this.isDisplay = true;
        }).catch((response:any) =>{
            if (response && response.status === 401) {
                return;
            }
            this.remoteData = {};
            this.isDisplay = true;
            this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.errorMessage });
        })
    }
</#if>
<#assign uiActionCount = 0/>
<#if ctrl.getPSAppViewLogics()??>
<#list ctrl.getPSAppViewLogics() as logic>
<#if logic.getPSAppViewUIAction().getPSUIAction()??>
<#assign uiActionCount += 1/>
</#if>
</#list>
</#if>
<#if uiActionCount gt 0>

    /**
     * 界面行为
     *
     * @param {*} row
     * @param {*} tag
     * @param {*} $event
     * @memberof ${srfclassname(ctrl.codeName)}${srfclassname(ctrl.getControlType()?lower_case)}Base
     */
	public uiAction(row: any, tag: any, $event: any): void {
        $event.stopPropagation();
        <#if ctrl.getPSAppViewLogics()??>
        <#list ctrl.getPSAppViewLogics() as logic>
        <#if logic.getPSAppViewUIAction().getPSUIAction()??>
        <#assign action = logic.getPSAppViewUIAction().getPSUIAction()>
        if(Object.is('${action.getUIActionTag()}', tag)) {
            this.${logic.getName()}(row, tag, $event);
        }
        </#if>
        </#list>
        </#if>
    }
</#if>
<#if ctrl.isEnableRowEdit()>
<#--  计算行编辑监控数量  -->
<#assign gridEditItemChangeCount = 0/>
<#if ctrl.getPSDEGridEditItems()??>
<#list ctrl.getPSDEGridEditItems() as editItem>
<#if editItem.getPSDEGridEditItemUpdate()??>
<#assign gridEditItemChangeCount += 1/>
</#if>
</#list>
</#if>
<#if gridEditItemChangeCount gt 0>

    /**
     * 表格编辑项值变化
     *
     * @public
     * @param row 行数据
     * @param property 列编辑项名
     * @param row 列编辑项值
     * @returns {void}
     * @memberof ${srfclassname(ctrl.codeName)}${srfclassname(ctrl.getControlType()?lower_case)}Base
     */
    public gridEditItemChange(row: any, property: string, value: any, rowIndex: number): void {
        super.gridEditItemChange(row, property, value, rowIndex);
  <#if ctrl.getPSDEGridEditItems()??>
    <#list ctrl.getPSDEGridEditItems() as editItem>
      <#if editItem.getPSDEGridEditItemUpdate()??>
      <#assign itemUpdate=editItem.getPSDEGridEditItemUpdate()/>
        if(Object.is(property, '${editItem.name}')){
            const details: string[] = [<#list itemUpdate.getPSDEGEIUpdateDetails() as detail><#if detail_index gt 0>, </#if>'${detail.getPSDEGridColumnName()?lower_case}'</#list>];
            this.updateGridEditItem('${itemUpdate.getPSAppDEMethod().getCodeName()}', row, details, ${itemUpdate.isShowBusyIndicator()?c});
        }
      </#if>
    </#list>
  </#if>
    }
</#if>
</#if>
<#--  计算新建默认值是否存在  -->
<#assign createDefaultCount = 0/>
<#list ctrl.getPSDEGridEditItems() as editItem>
<#if (editItem.getCreateDV?? || editItem.getCreateDVT??) && (editItem.getCreateDV()?? || editItem.getCreateDVT()??)>
<#if !(editItem.getCreateDV() == '') || !(editItem.getCreateDVT() == '')>
<#assign createDefaultCount += 1/>
</#if>
</#if>
</#list>
<#if createDefaultCount gt 0>

    /**
     * 新建默认值
     * @param {*}  row 行数据
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public createDefault(row: any){                    
<#list ctrl.getPSDEGridEditItems() as editItem><#t>
  <#if (editItem.getCreateDV?? || editItem.getCreateDVT??) && (editItem.getCreateDV()?? || editItem.getCreateDVT()??) && (editItem.getCreateDV() !="" || editItem.getCreateDVT() !="")><#t>
        if (row.hasOwnProperty('${editItem.getCodeName()?lower_case}')) {
    <#if !(editItem.getCreateDVT() == '')><#t>
      <#-- 网页请求 -->
      <#if editItem.getCreateDVT() == 'CONTEXT'>
            row['${editItem.getCodeName()?lower_case}'] = this.viewparams['${editItem.getCreateDV()}'];
      <#-- 用户全局对象 -->
      <#elseif editItem.getCreateDVT() == 'SESSION'>
            row['${editItem.getCodeName()?lower_case}'] = this.context['${editItem.getCreateDV()}'];
      <#-- 当前应用数据 -->
      <#elseif editItem.getCreateDVT() == 'APPDATA'>
            row['${editItem.getCodeName()?lower_case}'] = this.context['${editItem.getCreateDV()}'];
      <#-- 当前操作用户(名称) -->
      <#elseif editItem.getCreateDVT() == 'OPERATORNAME'>
            row['${editItem.getCodeName()?lower_case}'] = this.context['srfusername'];
      <#-- 当前操作用户(编号) -->
      <#elseif editItem.getCreateDVT() == 'OPERATOR'>
            row['${editItem.getCodeName()?lower_case}'] = this.context['srfuserid'];
      <#-- 当前时间 -->
      <#elseif editItem.getCreateDVT() == 'CURTIME'>
            row['${editItem.getCodeName()?lower_case}'] = this.$util.dateFormat(new Date());
      <#-- 数据对象属性 -->
      <#elseif editItem.getCreateDVT() == 'PARAM'>
            row['${editItem.getCodeName()?lower_case}'] = this.computeDefaultValueWithParam("CREATE","${editItem.getCreateDV()}",row);
      </#if>
    <#else>
      <#-- 默认值 -->
        <#assign datatype=srfjavatype(editItem.getPSAppDEField().getStdDataType())>
            row['${editItem.getCodeName()?lower_case}'] = <#if datatype=='BigInteger' || datatype=='Integer' || datatype=='Double' || datatype=='Decimal' || datatype=='Float' || datatype=='BigDecimal'>${editItem.getCreateDV()}<#else>'${editItem.getCreateDV()}'</#if>;
    </#if>
        }
  </#if>
</#list>
    }

</#if>

    /**
     * 更新默认值
     * @param {*}  row 行数据
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public updateDefault(row: any){                    
<#list ctrl.getPSDEGridEditItems() as editItem><#t>
  <#if (editItem.getUpdateDV?? || editItem.getUpdateDVT??) && (editItem.getUpdateDV()?? || editItem.getUpdateDVT()??) && (editItem.getUpdateDV() !="" || editItem.getUpdateDVT() !="")><#t>
        if (row.hasOwnProperty('${editItem.getCodeName()?lower_case}') && !row.${editItem.getCodeName()?lower_case} && row.hasUpdated) {
    <#if !(editItem.getUpdateDVT() == '')><#t>
      <#-- 网页请求 -->
      <#if editItem.getUpdateDVT() == 'CONTEXT'>
            row['${editItem.getCodeName()?lower_case}'] = this.viewparams['${editItem.getUpdateDV()}'];
      <#-- 用户全局对象 -->
      <#elseif editItem.getUpdateDVT() == 'SESSION'>
            row['${editItem.getCodeName()?lower_case}'] = this.context['${editItem.getUpdateDV()}'];
      <#-- 当前应用数据 -->
      <#elseif editItem.getUpdateDVT() == 'APPDATA'>
            row['${editItem.getCodeName()?lower_case}'] = this.context['${editItem.getUpdateDV()}'];
      <#-- 当前操作用户(名称) -->
      <#elseif editItem.getUpdateDVT() == 'OPERATORNAME'>
            row['${editItem.getCodeName()?lower_case}'] = this.context['srfusername'];
      <#-- 当前操作用户(编号) -->
      <#elseif editItem.getUpdateDVT() == 'OPERATOR'>
            row['${editItem.getCodeName()?lower_case}'] = this.context['srfuserid'];
      <#-- 当前时间 -->
      <#elseif editItem.getUpdateDVT() == 'CURTIME'>
            row['${editItem.getCodeName()?lower_case}'] = this.$util.dateFormat(new Date());
      <#-- 数据对象属性 -->
      <#elseif editItem.getUpdateDVT() == 'PARAM'>
            row['${editItem.getCodeName()?lower_case}'] = this.computeDefaultValueWithParam("UPDATE","${editItem.getUpdateDV()}",row);
      </#if>
    <#else>
        <#-- 默认值 -->
        <#assign datatype=srfjavatype(editItem.getPSAppDEField().getStdDataType())>
            row['${editItem.getCodeName()?lower_case}'] = <#if datatype=='BigInteger' || datatype=='Integer' || datatype=='Double' || datatype=='Decimal' || datatype=='Float' || datatype=='BigDecimal'>${editItem.getUpdateDV()}<#else>'${editItem.getUpdateDV()}'</#if>;
    </#if>
        }
  </#if>
</#list>
    }

    /**
     * 计算数据对象类型的默认值
     * @param {string}  action 行为
     * @param {string}  param 默认值参数
     * @param {*}  data 当前行数据
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public computeDefaultValueWithParam(action:string,param:string,data:any){
        if(Object.is(action,"UPDATE")){
            const nativeData:any = this.service.getCopynativeData();
            if(nativeData && (nativeData instanceof Array) && nativeData.length >0){
                let targetData:any = nativeData.find((item:any) =>{
                    return item.${appde.getKeyPSAppDEField().getCodeName()?lower_case} === data.srfkey;
                })
                if(targetData){
                    return targetData[param]?targetData[param]:null;
                }else{
                    return null;
                }
            }else{
                return null;
            }
        }else{
           return this.service.getRemoteCopyData()[param]?this.service.getRemoteCopyData()[param]:null;
        }
    }

<#if customBlock??>
${customBlock}
</#if>

<#ibizinclude>
../@MACRO/CONTROL/CONTROL_BOTTOM-BASE.vue.ftl
</#ibizinclude>